

package ivan.cheng.adapter;

import ivan.cheng.R;
import ivan.cheng.utils.LogUtil;
import ivan.cheng.utils.Util;

import java.util.ArrayList;

import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

public class PermissionExplainListAdapters {

    public final static class PermissionExplainListAdapter extends BaseAdapter {
        private LayoutInflater mInflater;
        private ArrayList<String> permissionLst;
        private Activity ctx;
        private PackageManager pm;

        public PermissionExplainListAdapter(Activity context, ArrayList<String> permissionLst) {
            // Cache the LayoutInflate to avoid asking for a new one each time.
            mInflater = LayoutInflater.from(context);
            this.permissionLst = permissionLst;
            this.ctx = context;
            this.pm = ctx.getPackageManager();
        }

        public void SetData(ArrayList<String> permissionLst)
        {
        	this.permissionLst = permissionLst;
        }
        
        public int getCount() {
            return permissionLst.size();
        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(final int position, View convertView, ViewGroup parent) {

            if (convertView == null) {
                convertView = new TextView(ctx);
            } 
            ((TextView)convertView).setText(Html.fromHtml(permissionLst.get(position)));
            return convertView;
        }

    }
}
